using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using Forecast.Business;

public partial class controls_grids_Medals : System.Web.UI.UserControl
{
    protected void Page_Load(object sender, EventArgs e)
    {
        Activity activity = new Activity(ConfigurationManager.ConnectionStrings["ForecastDB"].ConnectionString);
        int playerId = Convert.ToInt32(Request.QueryString["traderid"]);
        DataTable offerTable = activity.GetMedalsForPlayer(playerId);

        GridView1.DataSource = offerTable;
        GridView1.DataBind();

        if (offerTable.Rows.Count == 0)
        {
            _panel.Visible = false;
        }
        else
            _panel.GroupingText = "Medals won";
    }

    protected string GetMedalIcon(int medalId)
    {
        if (medalId == 2) // Predictum
            return "images/silk/award_star_gold_2.png";
        else if (medalId == 3) // Fatalum
            return "images/silk/award_star_gold_1.png";
        return "";
    }

    protected string GetMedalText(int medalId)
    {
        if (medalId == 2) // Predictum
            return "The most cash earned trading a successful prediction";
        else if (medalId == 3) // Fatalum
            return "The most cash earned trading a failed prediction";
        return "";
    }
}
